#include<bits/stdc++.h>
using namespace std;
const int N=3005;
const double eps=1e-10;
int T,n,m,L,V;
struct node{
	int d,v,a;
}car[N];
int p[N];
int chao[N];
string vis[N];
int tot;
map<string,int>l;
map<string,int>r;
string s[N];
bool cmp(string a,string b){
	if(r[a]!=r[b]) return l[a]<l[b];
	return r[a]<r[b];
}
int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>T;
	while(T--){
		bool yun=true;
		tot=0;
		cin>>n>>m>>L>>V;
		for(int i=1;i<=n;i++){
			vis[i]="";
			for(int j=1;j<=m;j++)
			 vis[i]+='0';
		 }
		for(int i=1;i<=n;i++){
			cin>>car[i].d>>car[i].v>>car[i].a;
			if(car[i].a!=0) yun=false;
		}
		for(int i=1;i<=m;i++) cin>>p[i];
		for(int i=1;i<=n;i++){
			int left;
			int righ;
			for(int j=1;j<=m;j++){
				if(car[i].d>p[j]) continue;
				int s=p[j]-car[i].d;
				int v=car[i].v,a=car[i].a;
				//double t=-1.0*v/a;
				//if(v*t+0.5*a*t*t+eps<s) continue;
				if(v*v+2*a*s>V*V){// speed more than std speed
					if(chao[tot]!=i){ 
						left=j-1;
						chao[++tot]=i;
					}
					righ=j-1;
					vis[i][j-1]='1';
				}
			}
			l[vis[i]]=left;
			r[vis[i]]=righ;
		}
		cout<<tot<<" ";
		for(int i=1;i<=tot;i++) s[i]=vis[chao[i]]; 
		sort(s+1,s+tot+1,cmp);
		if(yun){
			int last=1;
			for(int i=2;i<=tot;i++){
				if(l[s[i]]!=l[s[i-1]]){
					last++;
				}
			}
			cout<<n-last<<'\n';
			continue;
		}
		//s 1~tot
		//for(int i=1;i<=tot;i++) cout<<s[i]<<" "<<l[s[i]]<<" "<<r[s[i]]<<endl;
		int righ=0,idx=1;
		int last=0;
		while(idx<=tot){
			while(idx<=tot&&l[s[idx]]<=righ) idx++;
			if(idx>tot) break;
			if(righ<r[s[idx]]){
				righ=r[s[idx]];
				last++;
			}
			//cout<<righ<<" "<<idx<<endl;
		}
		cout<<n-last<<'\n';
	}
	return 0;
}
